package com.liang.cloud.Util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * @author: 余亮亮
 * @description:
 * @create: 2020-01-02 17:11:50
 **/
public class JsonUtil {

    public static String toJson(Object object){
        //Gson gson = new GsonBuilder().setPrettyPrinting().create();
        GsonBuilder gsonBuilder = new GsonBuilder();
        //格式化字符串至固定格式
        gsonBuilder.setPrettyPrinting();
        //简单Bean转化为Json==={
        //  "Name": "李坤",
        //  "bir": "2012-06-22 21:26:40:592"
        //}
        Gson gson = gsonBuilder.create();
        return gson.toJson(object);
    }
}
